<template>
	<view>
		<view class="orderList">
			<view class="headConTwo" v-if="1==order_data.serv_enum">
				<view class="addressCon">
					<view class="linesolid"></view>
					<view class="addressname">
						<view class="drop"></view>
						<view class="detail">{{order_data.departure}}</view>
					</view>
					<view class="addressname mtop">
						<view class="drop"></view>
						<view class="detail">{{order_data.destination}}</view>
					</view>
				</view>
				<view class="state right">{{order_data.status_text}}</view>
			</view>
			<view class="headConTwo" v-else>
				<view class="addressCon">
					
					<view class="addressname">
						
						<view class="detail">{{order_data.destination}}</view>
					</view>
					<view class="addressname mtop">
						
						<view class="detail"></view>
					</view>
				</view>
				<view class="state right">{{order_data.status_text}}</view>
			</view>
			<view class="cao">
				<view class="time top">{{order_data.createtime}}</view>
			</view>
		</view>
		<view class="cons">
			<view class="titlename"><text class="redcolors">*</text>投诉原因</view>
			<view class="wen">
				<textarea v-model="order_data.complaint_note" :disabled="5==order_data.status||0==order_data.status" cols="30" rows="10" placeholder-class="hui" placeholder="请输入投诉原因，我们将及时上报平台以保证您的权益"></textarea>
			</view>
		</view>
		<view class="foot" v-show="4==order_data.status">
			<view class="operate" @click="complaint_order">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				order_id:'',
				order_data:{},
				is_loaded:false,
			}
		},
		onLoad(option){
			this.order_id = option.order_id;
			this.load_data();
		},
		methods: {
			async complaint_order(){
				var order_id = this.order_id;
				await uni.request({
					url: '/dispatch/home/complaintOrder',
					data: {
						order_id:this.order_id,
						complaint_note:this.order_data.complaint_note,
					},
					method:"POST",
					success: res => {
						console.log("更新列表")
						// setTimeout(()=>{
						// 		this.load_data();
						// },100);
						uni.showModal({
							content: '投诉成功',
							success: res => {
								if (res.confirm) {
									uni.navigateBack();
									console.log('投诉成功');
								}else{
									console.log('失败');
									this.load_data();
								}
							}
						});

					},
					complete:()=>{

					}
				});	
			},
			async load_data(){
				// 获取列表
				await uni.request({
					url: '/dispatch/home/getOrderDetail',
					data: {
						order_id:this.order_id
					},
					method:"POST",
					success: res => {
						this.order_data = res.data;
						this.is_loaded = true;
						// this.list = this.list.concat(res.data);
						console.log(res);
					},
					complete:()=>{
					}
				});	
			},
		}
	}
</script>

<style>
	.orderList {
		width: 690rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		margin-left: 30rpx;
		margin-top: 30rpx;
		padding-top: 46rpx;
		padding-bottom: 36rpx;
	}

	.headCon {
		width: 630rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-left: 30rpx;
	}

	.headConTwo {
		width: 630rpx;
		display: flex;
		justify-content: space-between;
		margin-left: 30rpx;
		padding-bottom: 20rpx;
	}

	.headName {
		font-size: 36rpx;
		color: #3D3D3D;
	}

	.state {
		font-size: 26rpx;
		color: #84BD00;
	}







	.drop {
		width: 14rpx;
		height: 14rpx;
		background-color: #D8D8D8;
		border-radius: 50%;
		margin-right: 20rpx;
	}

	.addressCon {
		width: 500rpx;
		position: relative;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
	}

	.linesolid {
		position: absolute;
		left: 7rpx;
		border-left: 1px dashed #D8D8D8;
		height: 60%;
	}

	.addressname {
		font-size: 30rpx;
		color: #333333;
		display: flex;
		align-items: center;
	}

	.detail {
		width: 466rpx;
	}

	.mtop {
		margin-top: 20rpx;
	}

	.right {
		margin-right: 0;
	}

	.top {
		margin-top: 0;
	}

	.cao {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.ts {
		width: 162rpx;
		height: 54rpx;
		border-radius: 50rpx;
		border: 1px solid #DBDBDB;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 26rpx;
		color: #333333;
		margin-right: 30rpx;
	}

	.time {
		margin-left: 30rpx;
		font-size: 26rpx;
		color: #999999;
	}

	.foot {
		width: 100%;
		position: fixed;
		bottom: 70rpx;
		padding-bottom: env(safe-area-inset-bottom);
		display: flex;
		justify-content: center;
	}

	.operate {
		width: 678rpx;
		background-color: #84BD00;
		color: #ffffff;
		font-size: 32rpx;
		border-radius: 50rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 82rpx;
	}

	.cons {
		width: 690rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		margin-left: 30rpx;
		margin-top: 30rpx;
		padding-top: 40rpx;
		padding-bottom: 40rpx;
	}

	.titlename {
		width: 630rpx;
		margin-left: 30rpx;
		font-size: 30rpx;
		color: #3D3D3D;
	}

	.wen {
		width: 630rpx;
		height: 224rpx;
		margin-left: 30rpx;
		border-radius: 20rpx;
		background-color: #F6F6F6;
		margin-top: 36rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.redcolors {
		color: #FF0000;
	}
	textarea{
		width: 570rpx;
		height: 164rpx;
		font-size: 30rpx;
	}
	.hui{
		color: #CBCBCB;
	}
</style>